<%@ page import="com.autoMobile.bean.ddmUser" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>控制面板</title>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/styles.css">
</head>
<body style="background: transparent;">
    <div class="dashboard-container">
        <h2>我的用车状态</h2>
        <%
            ddmUser dqsq = (ddmUser) application.getAttribute("ddmUser");
            String name = dqsq.getZhuang();
            System.out.println("页面输出"+name);
            int i = 0;
            if ("申请".equals(name)) {
                i = 1;
            } else if ("填报".equals(name)) {
                i = 2;
            } else if ("使用中".equals(name)) {
                i = 3;
            } else if ("还车登记".equals(name)) {
                i = 4;
            } else if ("完成".equals(name)) {
                i = 5;
            }
            session.setAttribute("i", i);
            String[] cp =dqsq.getMessage().split(" - ");
            session.setAttribute("cp", cp);
        %>
        <!-- 流程状态展示 -->
        <div class="process-flow">
            <div class="process-step ${i>1 ? "completed" : ""} ${i==1 ? "active" : ""}">
                <div class="step-icon">1</div>
                <div class="step-info">
                    <h4>用车申请</h4>
                    <c:if test="${i>1}">
                    <p>已完成</p>
                    </c:if>
                    <c:if test="${i==1}">
                        <p>当前阶段</p>
                    </c:if>
                    <c:if test="${i<1}">
                        <p>待完成</p>
                    </c:if>
                </div>
            </div>
            <div class="process-step ${i>2?"completed":""} ${i==2?"active":""}" >
                <div class="step-icon">2</div>
                <div class="step-info">
                    <h4>车况填报</h4>
                    <c:if test="${i>2}">
                        <p>已完成</p>
                    </c:if>
                    <c:if test="${i==2}">
                        <p>当前阶段</p>
                    </c:if>
                    <c:if test="${i<2}">
                        <p>待完成</p>
                    </c:if>
                </div>
            </div>
            <div class="process-step ${i>3?"completed":""} ${i==3?"active":""}">
                <div class="step-icon">3</div>
                <div class="step-info">
                    <h4>使用中</h4>
                    <c:if test="${i>3}">
                        <p>已完成</p>
                    </c:if>
                    <c:if test="${i==3}">
                        <p>当前阶段</p>
                    </c:if>
                    <c:if test="${i<3}">
                        <p>待完成</p>
                    </c:if>
                </div>
            </div>
            <div class="process-step ${i>4?"completed":""} ${i==4?"active":""}">
                <div class="step-icon">4</div>
                <div class="step-info">
                    <h4>还车登记</h4>
                    <c:if test="${i>4}">
                        <p>已完成</p>
                    </c:if>
                    <c:if test="${i==4}">
                        <p>当前阶段</p>
                    </c:if>
                    <c:if test="${i<4}">
                        <p>待完成</p>
                    </c:if>
                </div>
            </div>
            <div class="process-step ${i==5?"active":""}">
                <div class="step-icon">5</div>
                <div class="step-info">
                    <h4>用车结束</h4>
                    <c:if test="${i>5}">
                        <p>已完成</p>
                    </c:if>
                    <c:if test="${i==5}">
                        <p>当前阶段</p>
                    </c:if>
                    <c:if test="${i<5}">
                        <p>待完成</p>
                    </c:if>
                </div>
            </div>
        </div>

        <!-- 当前用车信息 -->
        <div class="current-vehicle-info">
            <h3>当前用车信息</h3>
            <div class="info-grid">
                <div class="info-item">
                    <label>车牌号</label>
                    <span>${cp[0]}</span>
                </div>
                <div class="info-item">
                    <label>车型</label>
                    <span>${cp[1]}</span>
                </div>
                <div class="info-item">
                    <label>开始时间</label>
                    <span>${ddmUser.stime}</span>
                </div>
                <div class="info-item">
                    <label>预计结束</label>
                    <span>${ddmUser.otime}</span>
                </div>
                <div class="info-item">
                    <label>用途</label>
                    <span>${ddmUser.shiyong}</span>
                </div>
            </div>
            <div class="action-buttons">
                <button class="btn" onclick="location.href='<%=request.getContextPath()%>/employee/zhuangkuang.jsp'">填写车况</button>
                <button class="btn btn-warning" onclick="location.href='<%=request.getContextPath()%>/employee/accident-report.jsp'">报告事故</button>
                <button class="btn btn-primary" onclick="location.href='<%=request.getContextPath()%>/employee/return-vehicle.jsp'">申请还车</button>
            </div>
        </div>

        <!-- 最近用车记录 -->
        <div class="recent-records">
            <div class="section-header">
                <h3>最近用车记录</h3>
                <a href="my-records.jsp" class="btn btn-small btn-secondary">查看全部</a>
            </div>
            <table class="table">
                <thead>
                <c:forEach items="${ddmUserList}" var="user">
                    <tr>
                        <td>${user.otime }</td>
                        <td>${user.message}</td>
                        <td>${user.shiyong }</td>
                        <td><span class="status-tag status-completed">${user.zhuang }</td>
                    </tr>
                </c:forEach>
                </thead>
            </table>
        </div>
    </div>
</body>
</html> 